import java.util.HashSet;
import java.util.Scanner;

/**
 * 密码验证合格程序
 * 密码要求:
 * 1.长度超过8位
 * 2.包括大小写字母.数字.其它符号,以上四种至少三种
 * 3.不能有长度大于2的包含公共元素的子串重复 （注：其他符号不含空格或换行）
 */
public class HJ20 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            HashSet<String> set = new HashSet<>();
            String str = scanner.nextLine();

            boolean lengthFlag = false;
            boolean signFlag = false;
            boolean repeatFlag = false;

            if(str.length() > 8) lengthFlag = true;

            int lowCount = 0;
            int upCount = 0;
            int numCount = 0;
            int signCount = 0;
            for (int i = 0; i < str.length(); i++) {
                char c = str.charAt(i);
                if(c>='a' && c<='z'){
                    lowCount = 1;
                }else if(c>='A' && c<='Z'){
                    upCount = 1;
                }else if(c>='0' && c<='9'){
                    numCount = 1;
                }else {
                    signCount = 1;
                }
            }

            if((upCount+lowCount+numCount+signCount)>=3){
                signFlag = true;
            }

            for (int i = 0; i < str.length() - 3; i++) {
                if(!set.add(str.substring(i,i+3))){
                    repeatFlag = true;
                }
            }

            if(lengthFlag && signFlag && !repeatFlag){
                System.out.println("OK");
            }else {
                System.out.println("NG");
            }
        }
    }

}
